package com.gy.smartmanagement.base.api.interceptor;

import com.gy.smartmanagement.base.app.AppApplication;
import com.gy.smartmanagement.utils.ConstanceValue;

import java.io.IOException;

import androidx.annotation.NonNull;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by tl on 2018-8-9
 * 请求头拦截器
 */
public class HeadInterceptor implements Interceptor {

  @Override
  public Response intercept(@NonNull Chain chain) throws IOException {
    String token= (String) AppApplication.getInstance().getCacheData(ConstanceValue.TOKEN,"");
    Request request = chain.request()
        .newBuilder()
        .addHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
        .addHeader("Accept-Encoding", "gzip, deflate")
        .addHeader("Accept", "*/*")
        .addHeader("token",token)
        .build();
    return chain.proceed(request);
  }

}
